//
//  XHEditTableViewCell.m
//  Big Show
//
//  Created by 赵晓航 on 15-5-15.
//  Copyright (c) 2015年 Big_Q. All rights reserved.
//

#import "XHEditTableViewCell.h"
#import "UIImageView+WebCache.h"

@interface XHEditTableViewCell ()

@property (nonatomic, retain) UIImageView *imageView1;
@property (nonatomic, retain) UIImageView *imageView2;
@property (nonatomic, retain) UIImageView *imageView3;
@property (nonatomic, retain) UILabel *label1;

@end




@implementation XHEditTableViewCell

- (void)dealloc
{
    [_imageView1 release];
    [_imageView2 release];
    [_imageView3 release];
    [_label1 release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.contentView.backgroundColor = [UIColor clearColor];
        
        self.imageView1 = [[UIImageView alloc] init];
//        _imageView1.backgroundColor = [UIColor orangeColor];
        [self.contentView addSubview:_imageView1];
        [_imageView1 release];
        
        self.imageView2 = [[UIImageView alloc] init];
//        _imageView2.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_imageView2];
        [_imageView2 release];
        
        self.imageView3 = [[UIImageView alloc] init];
//        _imageView3.backgroundColor = [UIColor yellowColor];
        [self.contentView addSubview:_imageView3];
        [_imageView3 release];
        
        self.label1 = [[UILabel alloc] init];
//        _label1.backgroundColor = [UIColor lightGrayColor];
        _label1.textColor = [UIColor blackColor];

        _label1.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:_label1];
        [_label1 release];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    _label1.frame = CGRectMake(5,10, self.contentView.frame.size.width - 20, self.contentView.frame.size.height / 6);
    _imageView1.frame = CGRectMake(5, _label1.frame.size.height + 15, (self.contentView.frame.size.width - 20) / 3, self.contentView.frame.size.height / 1.5);
    _imageView2.frame = CGRectMake(5 + _imageView1.frame.size.width + 5, _label1.frame.size.height + 15, _imageView1.frame.size.width, _imageView1.frame.size.height);
    _imageView3.frame = CGRectMake(10 + _imageView1.frame.size.width + _imageView2.frame.size.width + 5, _label1.frame.size.height + 15, _imageView2.frame.size.width, _imageView2.frame.size.height);
    
    
    
}




-(void) setDic:(NSDictionary *)dic
{
    if (_dic != dic) {
        [_dic release];
        _dic = [dic retain];
    }
    if ([[dic objectForKey:@"image_urls"] count] == 3) {
    
    _label1.text = [_dic objectForKey:@"title"];
    NSString *imgPath = [NSString stringWithFormat:@"http://i1.go2yd.com/image.php?type=thumbnail_178x132&url=%@&news_id=09H0GEnH", [dic objectForKey:@"image"]];
    [_imageView1 sd_setImageWithURL:[NSURL URLWithString:imgPath]];
    NSString *imgPath1 = [NSString stringWithFormat:@"http://i1.go2yd.com/image.php?type=thumbnail_178x132&url=%@&news_id=09H0GEnH", [[dic objectForKey:@"image_urls"] objectAtIndex:1]];
    [_imageView2 sd_setImageWithURL:[NSURL URLWithString:imgPath1]];
    NSString *imgPath2 = [NSString stringWithFormat:@"http://i1.go2yd.com/image.php?type=thumbnail_178x132&url=%@&news_id=09H0GEnH", [[dic objectForKey:@"image_urls"] objectAtIndex:2]];
    [_imageView3 sd_setImageWithURL:[NSURL URLWithString:imgPath2]];
    }
}







- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
